//
// Created by Administrator on 2023/7/28.
//
#include <iostream>


using namespace std;

class Solution {
public:
    int sumOfMultiples(int n) {
        int ans = 0;
        for (int i = 0; i <= n; ++i) {
            if (i % 7 == 0 || i % 5 == 0 || i % 3 == 0) {
                ans += i;
            }
        }
        return ans;
    }
};

int main() {
    Solution s;
    cout << s.sumOfMultiples(7) << endl;
    cout << s.sumOfMultiples(10) << endl;
    cout << s.sumOfMultiples(9) << endl;
}